﻿using System.IO;

namespace Codemonk.Updater
{
    /// <summary>
    /// 流辅助类
    /// </summary>
    internal static class StreamHelper
    {
        /// <summary>
        /// 流转换
        /// </summary>
        /// <param name="inStream">输入流</param>
        /// <returns>内存流</returns>
        public static MemoryStream Transfer(Stream inStream, int bufferSize = 1024)
        {
            MemoryStream outStream = new MemoryStream();
            byte[] array = new byte[bufferSize];
            int count;
            while ((count = inStream.Read(array, 0, array.Length)) != 0)
            {
                outStream.Write(array, 0, count);
            }
            outStream.Seek(0, SeekOrigin.Begin);
            return outStream;
        }
    }
}
